function loadImg(src) {
    let promise = new Promise((resolve, reject) => {
        let img = document.createElement('img');
        img.onload = () => {
            resolvev(img)
        }
        img.onerror = () => {
            reject('图片加载失败')
        }
    })
    return promise;
}

let src = 'https://tva1.sinaimg.cn/large/007S8ZIlly1ghuzmru0y6j31440hmdhu.jpg';
let result = loadImg(src);
result.then(img => {
    console.log('img.width', img.width);
    return img;
}).then(img => {
    console.log('img.height', img.height)
}).catch(error => {
    // 统一捕获异常
    console.log(error)
})